#include "../images/ui.h"
#include "ui_helpers.h"
#include "fat.h"
lv_obj_t * ui_cleardataFollow;

lv_obj_t * ui_cleardataLabel2;
void ui_event_yesButton1(lv_event_t * e);
lv_obj_t * ui_yesButton1;
lv_obj_t * ui_uiabout_Label4;
void ui_event_noButton2(lv_event_t * e);
lv_obj_t * ui_noButton2;
lv_obj_t * ui_uiabout_Label3;
void ui_event_yesButton1(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
			   ClearAllData();
					printf("clear data");
			g_total_files=0;
         lv_scr_load_anim(ui_SettingsUnit,LV_SCR_LOAD_ANIM_NONE, 10, 0,true);
    }
}
void ui_event_noButton2(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
         lv_scr_load_anim(ui_SettingsUnit,LV_SCR_LOAD_ANIM_NONE, 10, 0,true);
    }
}
void ui_cleardata_screen_init(void)
{
    ui_cleardataFollow = lv_obj_create(NULL);
    lv_obj_clear_flag(ui_cleardataFollow, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_bg_color(ui_cleardataFollow, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_cleardataFollow, 255, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_cleardataPanel = lv_obj_create(ui_cleardataFollow);
    lv_obj_set_width(ui_cleardataPanel, 240);
    lv_obj_set_height(ui_cleardataPanel, 223);
    lv_obj_set_x(ui_cleardataPanel, 0);
    lv_obj_set_y(ui_cleardataPanel, 60);
    lv_obj_clear_flag(ui_cleardataPanel, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_radius(ui_cleardataPanel, 20, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_color(ui_cleardataPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_cleardataPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_border_width(ui_cleardataPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_noButton = lv_btn_create(ui_cleardataPanel);
    lv_obj_set_width(ui_noButton, 100);
    lv_obj_set_height(ui_noButton, 60);
    lv_obj_set_x(ui_noButton, -64);
    lv_obj_set_y(ui_noButton, 60);
    lv_obj_set_align(ui_noButton, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_noButton, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags
    lv_obj_clear_flag(ui_noButton, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_bg_color(ui_noButton, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_noButton, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_color(ui_noButton, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_opa(ui_noButton, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_width(ui_noButton, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_pad(ui_noButton, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

    ui_yesButton1 = lv_btn_create(ui_cleardataPanel);
    lv_obj_set_width(ui_yesButton1, 100);
    lv_obj_set_height(ui_yesButton1, 60);
    lv_obj_set_x(ui_yesButton1, 64);
    lv_obj_set_y(ui_yesButton1, 60);
    lv_obj_set_align(ui_yesButton1, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_yesButton1, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags
    lv_obj_clear_flag(ui_yesButton1, LV_OBJ_FLAG_SCROLLABLE);      /// Flags
    lv_obj_set_style_bg_color(ui_yesButton1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_bg_opa(ui_yesButton1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_color(ui_yesButton1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_opa(ui_yesButton1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_width(ui_yesButton1, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_outline_pad(ui_yesButton1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t *ui_cleardataFollow_Label8 = lv_label_create(ui_cleardataPanel);
    lv_obj_set_width(ui_cleardataFollow_Label8, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_cleardataFollow_Label8, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_cleardataFollow_Label8, 0);
    lv_obj_set_y(ui_cleardataFollow_Label8, -30);
    lv_obj_set_align(ui_cleardataFollow_Label8, LV_ALIGN_CENTER);
    lv_label_set_text(ui_cleardataFollow_Label8, "clear all data of device?");
    lv_obj_set_style_text_font(ui_cleardataFollow_Label8, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t* ui_cleardataFollow_Label7 = lv_label_create(ui_cleardataFollow);
    lv_obj_set_width(ui_cleardataFollow_Label7, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_cleardataFollow_Label7, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_cleardataFollow_Label7, 0);
    lv_obj_set_y(ui_cleardataFollow_Label7, 10);
    lv_obj_set_align(ui_cleardataFollow_Label7, LV_ALIGN_TOP_MID);
    lv_label_set_text(ui_cleardataFollow_Label7, "Clear Data");
    lv_obj_set_style_text_color(ui_cleardataFollow_Label7, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui_cleardataFollow_Label7, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_font(ui_cleardataFollow_Label7, &lv_font_montserrat_24, LV_PART_MAIN | LV_STATE_DEFAULT);

    lv_obj_t* ui_yesLabel1 = lv_label_create(ui_cleardataFollow);
    lv_obj_set_width(ui_yesLabel1, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_yesLabel1, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_yesLabel1, 63);
    lv_obj_set_y(ui_yesLabel1, 90);
    lv_obj_set_align(ui_yesLabel1, LV_ALIGN_CENTER);
    lv_label_set_text(ui_yesLabel1, "Yes");

    lv_obj_t* ui_yesLabel2 = lv_label_create(ui_cleardataFollow);
    lv_obj_set_width(ui_yesLabel2, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_yesLabel2, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_yesLabel2, -63);
    lv_obj_set_y(ui_yesLabel2, 90);
    lv_obj_set_align(ui_yesLabel2, LV_ALIGN_CENTER);
    lv_label_set_text(ui_yesLabel2, "No");
     lv_obj_add_event_cb(ui_yesButton1, ui_event_yesButton1, LV_EVENT_ALL, NULL);
     lv_obj_add_event_cb(ui_noButton, ui_event_noButton2, LV_EVENT_ALL, NULL);

}
void clearData_caller(lv_event_t *e)
{
    ui_cleardata_screen_init();
    lv_disp_load_scr(ui_cleardataFollow);
}